/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package makai.toolbox;

import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 * All things in the Tool Box must extend this class.  Tools are operated by
 * listening to Mouse, Key, and Tablet events on the Canvas.
 * 
 * When selected the Engine will attach it to the canvas.
 * When deselected the Engine will detach it from the canvas.
 * 
 * @author Krechevskoy
 * @version 0.0
 */
public abstract class Tool {
    
    private final String name;
    private Icon icon;
    
    public Tool(String name) {
        this(name, new ImageIcon());
    }
    
    public Tool(String name, Icon icon) {
        this.name = name;
        this.icon = icon;
    }
    
    public abstract boolean attach();
    
    public abstract boolean detach();
    
    /**
     * Sets the Icon used to represent this tool.
     * Once a tool has been added to the toolbox it's icon will not be updated.
     * 
     * @param icon The icon to be used by this tool.
     */
    public void setIcon(Icon icon){
        this.icon = icon;
    }
    
    public String getName(){
        return name;
    }

    @Override
    public String toString() {
        return "Tool["+getName()+"]";
    }
    
}
